﻿import {createRouter, createWebHistory, createWebHashHistory} from "vue-router";


import Layout from '@/layout/index.vue'
import NotFoundPage from '@/view/NotFound.vue'

// const routesJson = {
//     redirect: path, //重定向路径
//     alwaysShow: Boolean, //菜单栏是否一直显示
//     meta: {
//         roles: Array,//角色权限
//         breadcrumb: boolean,//面包屑是否显示菜单
//         activeMenu: string,//高亮的菜单路径
//         icon: string, //icon fill name
//         elSvgIcon: string, //element icon name
//         cachePage: boolean, //是否缓存页面
//         leaveRmCachePage: boolean //离开是否删除缓存
//     }
// }


export const constantRoutes = [
    {
        path: '/redirect',
        component: Layout,
        hidden: true,
        children: [
            {
                path: '/redirect/:path(.*)',
                component: () => import('@/view/redirect')
            }
        ]
    },
    {
        path: '/',
        component: Layout,
        redirect: '/home',
        children: [
            {
                path: 'home',
                name: 'Home',
                component: () => import('@/view/home/index.vue'),
                //using el svg icon, the elSvgIcon first when at the same time using elSvgIcon and icon
                meta: {title: '首页', icon: 'table'}
            }
        ]
    },
    {
        path: '/404',
        component: NotFoundPage,
        hidden: true
    },
    // {
    //     path: '/external-link',
    //     component: Layout,
    //     children: [
    //         {
    //             path: 'https://github.com/jzfai/vue3-admin-template.git',
    //             meta: {title: '外部链接', icon: 'link'}
    //         }
    //     ]
    // },
    // 将匹配所有内容并将其放在 `$route.params.pathMatch` 下
    {path: '/:pathMatch(.*)', redirect: '/404', hidden: true},
    // {path: '/:pathMatch(.*)*', name: 'NotFoundPage', component: NotFoundPage},

]
export const asyncRoutes = [
    {
        path: '/system_manage',
        component: Layout,
        redirect: '/system_manage/index',
        children: [
            {
                path: 'index',
                name: 'system_manage',
                component: () => import('@/view/system_manage/index.vue'),
                meta: {title: '系统管理', icon: 'table', isCache: true},
            }
        ]
    },
    {
        path: '/material_manage',
        component: Layout,
        children: [
            {
                path: 'index',
                name: 'material_manage',
                component: () => import('@/view/material_manage/index.vue'),
                meta: {title: '物资管理', icon: 'table'},
            }
        ]
    },
    {
        path: '/equipment_maintenance',
        component: Layout,
        children: [
            {
                path: 'index',
                name: 'equipment_maintenance',
                component: () => import('@/view/equipment_maintenance/index.vue'),
                meta: {title: '设备检维修', icon: 'table'},
            }
        ]
    },
    {
        path: '/train_manage',
        redirect: '/train_manage/my_train',
        alwaysShow: true, // will always show the root menu
        component: Layout,
        meta: {title: '培训管理', icon: 'table', roles: ['admin']},
        children: [
            {
                path: 'my_train',
                name: 'my_train',
                component: () => import('@/view/train_manage/my_train/index.vue'),
                meta: {title: '我的培训', icon: ''},
            },
            {
                path: 'online_answer_desc',
                name: 'online_answer_desc',
                hidden: true,
                component: () => import('@/view/train_manage/my_train/online_answer_desc.vue'),
                meta: {title: '线上答题详情', activeMenu: '/train_manage/my_train'},
            },
            {
                path: 'answer_page',
                name: 'answer_page',
                hidden: true,
                component: () => import('@/view/train_manage/my_train/answer_page.vue'),
                meta: {title: '线上答题详情', activeMenu: '/train_manage/my_train'},
            },
            //
            {
                path: 'topic_manage',
                name: 'topic_manage',
                component: () => import('@/view/train_manage/topic_manage/index.vue'),
                meta: {title: '题目管理', icon: ''},

            },
            {
                path:'add_topic',
                name:'add_topic',
                hidden: true,
                component: () => import('@/view/train_manage/topic_manage/add.vue'),
                meta: {title: '题目管理_新增', icon: ''},
            },
            //
            {
                path: 'train_assess_classify',
                name: 'train_assess_classify',
                component: () => import('@/view/train_manage/train_assess_classify/index.vue'),
                meta: {title: '培训考核分类', icon: ''},
            },
            //
            {
                path: 'train_statistics',
                name: 'train_statistics',
                component: () => import('@/view/train_manage/train_statistics/index.vue'),
                meta: {title: '培训统计', icon: ''},
            },
            //
            {
                path: 'train_type',
                name: 'train_type',
                component: () => import('@/view/train_manage/train_type/index.vue'),
                meta: {title: '培训类型', icon: ''},
            },
            //
            {
                path: 'test_paper_manage',
                name: 'test_paper_manage',
                component: () => import('@/view/train_manage/test_paper_manage/index.vue'),
                meta: {title: '试卷管理', icon: ''},
            },
            //
            {
                path: 'train_activity',
                name: 'train_activity',
                component: () => import('@/view/train_manage/train_activity/index.vue'),
                meta: {title: '培训活动', icon: ''},
            },
            //
            {
                path: 'team_knowledge_base',
                name: 'team_knowledge_base',
                component: () => import('@/view/train_manage/team_knowledge_base/index.vue'),
                meta: {title: '团队知识库-知识分类', icon: ''},
            },
            //
        ]
    }
]
const router = createRouter({
    history: createWebHashHistory(),
    scrollBehavior: () => ({top: 0}),
    routes: constantRoutes.concat(asyncRoutes)
})

export default router
